/*
    commandline.h
*/
#ifndef __MINIUTIL_UTIL_COMMANDLINE_H__
#define __MINIUTIL_UTIL_COMMANDLINE_H__

#include <string>
#include <vector>
#include <map>

namespace miniutil { namespace util {

    struct OptionIndicator
    {
        std::string shortopt;
        std::string longopt;
        bool hasarg;
    };

/*
    CTypeCommandLineParser use to parse c type command line, such as
    myapp -p 1812 -m -s 192.168.1.173 -o
    and check if parameter is there
    format is as "s:p:m" just same as getopt's work
    and check parameter by CheckPara, if not set, it return -1
*/
    class CTypeCommandLineParser
    {
        public:
            CTypeCommandLineParser(const std::string& format);
            CTypeCommandLineParser(std::vector<OptionIndicator> voptions);
            int ParseCommandLine(const std::string&);      //first is app name
            int ParseCommandLine(int argc, char** argv);   //first is app name
            int ParseParaLine(const std::string&);  //first is not app name
            int CheckPara(const std::string& key, std::string &value);
            int SetFormat(const std::string& format);
        public:
            std::vector<OptionIndicator> mvoptions;
            std::vector<std::string> mvnotopt;
            std::map<std::string, std::string> mmparas;
            std::string appname;

    };

} }

#endif
